package com.jic.market.enums;

import java.util.EnumSet;

/**
 * @author : xuyongliang
 * @date : 2020/4/14
 * @description: 拼团团长标识  head_flag  1表示团长，0表示团员
 * @modified By:
 * @version: V1.0
 */
public enum GrouponHeadFlagEnum {
    
    //  拼团团长标识  head_flag  1表示团长，0表示团员
    GROUP_HEAD(1, "团长"),
    GROUP_MEMBER(0, "团员"),
    ;

    private Integer code;

    private String value;

    GrouponHeadFlagEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static GrouponHeadFlagEnum getEnumByCode(Integer code){
        EnumSet<GrouponHeadFlagEnum> elements = EnumSet.allOf(GrouponHeadFlagEnum.class);
        for(GrouponHeadFlagEnum enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static int getCodeByValue(String value) {
        for (GrouponHeadFlagEnum c : GrouponHeadFlagEnum.values()) {
            if (c.getValue().equals(value.trim())) {
                return c.code;
            }
        }
        return 0;
    }

    public static String getValue(Integer code) {
        return getEnumByCode(code).getValue();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
